<?php 
error_reporting(E_ERROR);
session_start();
require_once('constants_shop.php');
require_once('functions.php');
include('classes/userClass.php');



#conect to shop database	
$shopObj = new mysqlClass();
if(isset($_POST['get_client'])){
	$params=array($_POST['get_client']);
	$results=$shopObj->fetch_result("SELECT * FROM clients WHERE id=?",$params);
	echo json_encode($results);
}
if(isset($_POST['add_client'])){
	$params=array();
	$params['name']=$_POST['name'];
	$params['email']=$_POST['email'];
	$params['password']=$_POST['password'];
	$params['type']=$_POST['type'];
	$params['address']=$_POST['address'];
	$params['country_id']=$_POST['country'];
	$params['county_id']=$_POST['county'];
	$params['city_id']=$_POST['city'];
	$params['zip_code']=$_POST['zip_code'];
	$params['phone']=$_POST['phone'];
	$params['terms_and_conditions']=$_POST['terms_and_conditions'];
	$params['company_contact_name']=$_POST['company_contact_name'];
	$params['fax']=$_POST['fax'];
	$params['registration_number']=$_POST['registration_number'];
	$params['unique_code']=$_POST['unique_code'];
	$params['bank_name']=$_POST['bank_name'];
	$params['bank_account']=$_POST['bank_account'];
	$params['company_phone']=$_POST['company_phone'];
	$params['facebook_id']='';
	$params['login_key']='';
	if($_POST['add_client']==0){
		$last_id = $shopObj->insert('clients',$params);
	}else{
		$params['id']=$_POST['add_client'];
		$shopObj->update('clients',$params);
	}	
}
if(isset($_POST['delete_client'])){
	$params=array();
	$params['id']= $_POST['delete_client'];
	$shopObj->delete('clients',$params);
}
?>